<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class CategoryGoods extends Model
{
    use HasFactory;
    protected $table='sp_category_goods';
    protected $primaryKey='id';
    public $timestamps = false;

    protected function GetList($cate_id){
        $list = $this->from('sp_category_goods as c')->where([['g.ischeck',1],['c.status',1],['c.cate_id',$cate_id]])
            ->leftjoin('sp_goods_2 as g','c.goods_id','=','g.id')
            ->leftjoin('sp_category as a','g.category_id','=','a.id')
            ->select('c.cate_id','c.goods_id','c.goods_name','c.goods_img','g.status','g.title','g.imgurl','a.name as cate_name','g.min_price as day_price')
            ->orderBy('c.goods_sort','asc')
            ->get();
        $list = $list?$list->toArray():[];
        return $list;
    }
}


